
function refuse(obj){
    var orderId = obj.getAttribute("cid");
    let formData = new FormData();
    formData.append("orderId",orderId);
    $.ajax({
        url :"http://localhost:8022/orderBack",
        type:"POST",
        data:formData,
        processData: false,
        contentType: false,
        cache:false,
        async:false,
        success: function(data){
            $('#flashhtml').html(data);
        },
        error: function(errorMsg){
            console.log(errorMsg);
            console.log('error exist');
        }
    });
}
function agree(obj){
    var orderId = obj.getAttribute("cid");
    let formData = new FormData();
    formData.append("orderId",orderId);
    $.ajax({
        url:"http://localhost:8022/orderBack",
        type:"POST",
        data:formData,
        processData: false,
        contentType: false,
        cache:false,
        async:false,
        success: function(data){
            $('#flashhtml').html(data);
        },
        error: function(errorMsg){
            console.log(errorMsg);
            console.log('error exist');
        }
    });
}
function send(obj){
    var orderId = obj.getAttribute("cid");
    var statement = 1;
    let formData = new FormData();
    formData.append("orderId",orderId);
    formData.append("statement",statement);
    $.ajax({
        url:"http://localhost:8022/orderStatementChange",
        type:"POST",
        data:formData,
        processData: false,
        contentType: false,
        cache:false,
        async:false,
        success: function(data){
            $('#flashhtml').html(data);
        },
        error: function(errorMsg){
            console.log(errorMsg);
            console.log('error exist');
        }
    });
}
function submitform(obj){
    let form = obj.parentElement.parentElement;
    let formData = new FormData(form);
    var orderId = obj.id;
    formData.append("orderId",orderId)
    $.ajax({
        url:"http://localhost:8022/orderEdit",
        type:"POST",
        data:formData,
        processData: false,
        contentType: false,
        cache:false,
        async:false,
        success: function(data){
            $(".modal").modal('hide');
            $('#flashhtml').html(data);
        },
        error: function(errorMsg){
            console.log(errorMsg);
            console.log('error exist');
        }
    });
}

var logout = document.getElementById("btn-logout");

logout.addEventListener('click',onLogoutClick)

function onLogoutClick()
{
    console.log("logout")
    $.ajax(
        {
            type: 'GET',
            url: 'http://localhost:8022/logout',
            success: function (data)
            {
                console.log(data)
                if(data === 'success')
                {
                    window.location='http://localhost:8022/signIn'
                }
                else
                {
                    window.showAlert('注销失败')
                }
            },
            error: function (errorMag)
            {
                window.alert('注销失败')
                console.log(errorMag)
            }
        })
}
